package com.common.springbootcommonmessage.vo;

import com.common.springbootcommonmessage.model.CommonAutopartNotificationtemplate;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author korol *
 * @date 2022年12月08日 15:48
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class NotificationTemplateVo implements Serializable {
    private Integer id;

    private Integer messageType;

    private String title;

    private String template;

    private String text1;

    private String text2;

    private Boolean isAddTax;

    private String emailSubject;

    private String emailTemplate;

    private Integer mappingID;

    private String theClass;

    private Integer showInfo;

    private Boolean isPartsIssue;

    private Boolean isPriceIssue;

    private Boolean isPAIssueFollowUp;

    private String tutorial;

    private Integer sort;

    private String issueAction;

    private String header;

    private String actionButton;

    private String actionInformation;

    private String footer;

    private String issueCode;

    private Integer acType;

    private String commentsTip;

    private Boolean isPaymentConversion;

    private Boolean isPIIssueFollowUp;


    private String templateResult;

    private String emailSubjectResult;

    private String headerResult;

    private String actionResult;

    private String footerResult;

    private String actionInformationResult;

    private Boolean isShowPc;

    private Boolean isShowDiscountPc;

    private Boolean isDeleted;

    /**
     * 数据库对象转换为VO对象
     */
    public static NotificationTemplateVo transferToVo(CommonAutopartNotificationtemplate template) {

        NotificationTemplateVo retVo = null;

        if (template != null) {
            retVo = new NotificationTemplateVo();
            BeanUtils.copyProperties(template, retVo);
        }
        return retVo;
    }

    /**
     * 数据库对象转换为VO列表对象
     */
    public static List<NotificationTemplateVo> transferToVoList(List<CommonAutopartNotificationtemplate> templateList) {

        List<NotificationTemplateVo> retVoList = null;

        if (templateList != null && templateList.size() > 0) {
            retVoList = new ArrayList<NotificationTemplateVo>();
            for (CommonAutopartNotificationtemplate template : templateList) {
                NotificationTemplateVo retVo = transferToVo(template);
                if (retVo != null) retVoList.add(retVo);
            }
        }
        return retVoList;
    }
}
